package com.feihao.zhou.demoWeekEunm;

public class TestWeek {
    public static void main(String[] args) {

        //获取枚举类中所有的枚举对象：
        System.out.println("获取枚举类中所有的枚举对象：");
        Week[] values = Week.values();
        for (Week value : values) {
            System.out.println(value);
        }

        //获取指定枚举类的名称
        System.out.println("获取指定枚举类的名称:");
        String yi = Week.MONDAY.name();
        String er = Week.TUESDAY.name();
        System.out.println("星期一：" + yi);
        System.out.println("星期二：" + er);

        //获取指定枚举对象在枚举类中的索引：
        int ordinal = Week.TUESDAY.ordinal();
        System.out.println("星期2在枚举类中的索引："+ordinal);

        //获取指定枚举类中的指定名称的枚举值：
        Week monday = Enum.valueOf(Week.class, "MONDAY");
        System.out.println(monday);
        System.out.println(Week.MONDAY.equals(monday));

    }
}
